package com.yanggu.spock.service;

import com.yanggu.spock.domain.vo.OrderVO;
import com.yanggu.spock.domain.vo.UserVO;
import com.yanggu.spock.util.HttpContextUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderService {

    /**
     * 静态方法多分支场景
     */
    public List<OrderVO> getUserOrdersBySource(UserVO userVO) {
        List<OrderVO> orderList = new ArrayList<>();
        OrderVO order = new OrderVO();
        if ("APP".equals(HttpContextUtils.getCurrentSource())) { // 手机来源
            if ("CNY".equals(HttpContextUtils.getCurrentCurrency())) { // 人民币
                // TODO 针对App端的订单，并且请求币种为人民币的业务逻辑...
                System.out.println("source -> APP, currency -> CNY");
            } else {
                System.out.println("source -> APP, currency -> !CNY");
            }
            order.setType(1);
        } else if ("WAP".equals(HttpContextUtils.getCurrentSource())) { // H5来源
            // TODO 针对H5端的业务逻辑...
            System.out.println("source -> WAP");
            order.setType(2);
        } else if ("ONLINE".equals(HttpContextUtils.getCurrentSource())) { // PC来源
            // TODO 针对PC端的业务逻辑...
            System.out.println("source -> ONLINE");
            order.setType(3);
        }
        orderList.add(order);
        return orderList;
    }

}
